<?php

namespace app\agent\controller\order;

use think\facade\Db;
use app\agent\controller\Controller;
use app\agent\model\order\Mobile as MobileModel;

class Mobile extends Controller
{
    protected function initialize()
    {
        parent::initialize();
    }

    /**
     * 列表
     */
    public function list()
    {
        $model = new MobileModel;
        $data = input('post.');
        $data['agent'] = $this->agent;
        return $model->getList($data);
    }

    /**
     * Excel 批量导入
     */
    public function batchImport()
    {
        $model = new MobileModel;
        $data = input('post.');
        return $model->batchImport($data, $this->agent['id']);
    }

    /*
     * API 订单手动回调通知
     */
    public function manualNotify()
    {
        if (isProd()) {
            return fail('不行');
        }

        $model = new MobileModel();
        $data = input('post.');
        $data['agent_id'] = $this->agent['id'];

        $res = $model->manualNotify($data);
        if (false === $res) {
            return fail($model->getError());
        }

        return success('回调成功', $res);
    }
}
